<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
       // 数组和对象的解构赋值  等号左边要等于等号右边
       // let 和 var 是都是声明变量的，区别：作用域讲
       let obj={
          name:"lili",
          age:18,
          job:"ceo",
          cat:"大黑"
       }

       //对象解构赋值
       //cat:c 起别名
       //job="学生" 设置默认值
       let {name:na,age,job="学生",num,n=100,cat:c}=obj;

       console.log(age);//18
       console.log(num);//undefined  
       console.log(n);//100  
       console.log(job);//"ceo"
       console.log(na);//"lili"
       console.log(c);



       let arr=[10,20,30];
       let [a,b,cs,d="ccc"]=arr;
       console.log(a,b,cs,d);

       //交换两个数的值---解构赋值 可以直接交换
       let aa=10;
       let bb=20;
       [bb,aa]=[aa,bb];

       console.log(aa,bb);

       //解构赋值的方式接收参数---了解
    //    function show({a,b="暂无"}){
	//        	console.log(a,b);//1 暂无
	//    }
	//    show({a:1})


    function fn(){
        //.....
        return {
            e:101,
            f:201
        }
    }

    var {e,f}=fn();
    console.log(e,f);


    

    </script>
</body>
</html>